package testview.zhen.com.myapplication.material_design

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
import testview.zhen.com.myapplication.R
import testview.zhen.com.myapplication.databinding.ActivityCollapsingToolbarBinding
import testview.zhen.com.myapplication.databinding.ActivityMaterialDesignSampleBinding

class MaterialDesignSampleActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_material_design_sample)
        val binding = ActivityMaterialDesignSampleBinding.inflate(LayoutInflater.from(this))
        setContentView(binding.root)
        binding.floatButton.setOnClickListener {
            Snackbar.make(it, "点击进入可折叠标题栏", Snackbar.LENGTH_SHORT)
                    .setAction("进入") {
                        startActivity(Intent(this@MaterialDesignSampleActivity,CollapsingToolbarActivity::class.java))
//                        Toast.makeText(this@MaterialDesignSampleActivity, "Toast吐司显示", Toast.LENGTH_LONG).show()
                    }
                    .show()
        }

        val array = ArrayList<String>()
        for (i in 0..60){
            array.add("小明${i}")
        }
        val l = LinearLayoutManager(this)
        l.orientation = RecyclerView.VERTICAL
        binding.recycleView.layoutManager = l
        val s = SampleAdapter(this)
        s.setData(array)
        binding.recycleView.adapter = s
    }
}
